package com.wudd.common.bean.response;


import com.wudd.common.enums.ResultType;

import lombok.Data;



/**
 * 描述：统一返回类
 * @author 吴冬冬
 * @date 2018年11月7日 下午2:38:17  
 * @version V1.0
 */
@Data
public class ResponseVO<T> {
    private String result;
    private String msg;
    private Integer code;
    private T data;
    
    public ResponseVO() {
    	
    }

    public ResponseVO(String result, String msg, Integer code, T data) {
        this.result = result;
        this.msg = msg;
        this.code = code;
        this.data = data;
    }
    
    public ResponseVO(String result, String msg, Integer code) {
        this.result = result;
        this.msg = msg;
        this.code = code;
    }
    
    public static <T> ResponseVO<T> resultMsg(ResultType resultType) {
    	return new ResponseVO<T>(resultType.getResult(), resultType.getMsg(),resultType.getCode());
    }
    
    public static <T> ResponseVO<T> resultMsg(String result,Integer code,String msg) {
    	return new ResponseVO<T>(result, msg,code);
    }
    
    public static <T> ResponseVO<T> resultMsg(String result,Integer code,String msg,T data) {
    	return new ResponseVO<T>(result, result,code,data);
    }
    
    public static <T> ResponseVO<T> resultMsg(ResultType resultType, String msg) {
    	return new ResponseVO<T>(resultType.getResult(), msg, resultType.getCode());
    }
    
    public static <T> ResponseVO<T> resultWithData(ResultType resultType, T data) {
    	return new ResponseVO<T>(resultType.getResult(), resultType.getMsg(),resultType.getCode(),data);
    }
    
    public static <T> ResponseVO<T> resultWithData(ResultType resultType, T data, String msg) {
    	return new ResponseVO<T>(resultType.getResult(), msg,resultType.getCode(),data);
    }
    
    // 成功
    public static <T> ResponseVO<T> success() {
        return new ResponseVO<T>(ResultType.SUCCESS.getResult(), ResultType.SUCCESS.getMsg(),ResultType.SUCCESS.getCode());
    }
    
    public static <T> ResponseVO<T> success(String msg) {
        return new ResponseVO<T>(ResultType.SUCCESS.getResult(), msg,ResultType.SUCCESS.getCode());
    }

    public static <T> ResponseVO<T> successWithData(T data) {
    	return new ResponseVO<T>(ResultType.SUCCESS.getResult(), ResultType.SUCCESS.getMsg(),ResultType.SUCCESS.getCode(),data);
    }
    
    public static <T> ResponseVO<T> successWithData(T data,String msg) {
    	return new ResponseVO<T>(ResultType.SUCCESS.getResult(), msg,ResultType.SUCCESS.getCode(),data);
    }
    
    // 异常
    public static <T> ResponseVO<T> error() {
        return new ResponseVO<T>(ResultType.ERROR.getResult(), ResultType.ERROR.getMsg(),ResultType.ERROR.getCode());
    }
    
    public static <T> ResponseVO<T> error(String msg) {
        return new ResponseVO<T>(ResultType.ERROR.getResult(), msg,ResultType.ERROR.getCode());
    }

    public static <T> ResponseVO<T> errorWithData(T data) {
        return new ResponseVO<T>(ResultType.ERROR.getResult(), ResultType.ERROR.getMsg(),ResultType.ERROR.getCode(),data);
    }
    
    public static <T> ResponseVO<T> errorWithData(T data,String msg) {
        return new ResponseVO<T>(ResultType.ERROR.getResult(), msg, ResultType.ERROR.getCode(),data);
    }
    
    // 失败
    public static <T> ResponseVO<T> failure() {
        return new ResponseVO<T>(ResultType.FAILURE.getResult(), ResultType.FAILURE.getMsg(),ResultType.FAILURE.getCode());
    }
    
    public static <T> ResponseVO<T> failure(String msg) {
        return new ResponseVO<T>(ResultType.FAILURE.getResult(), msg,ResultType.FAILURE.getCode());
    }
    
    public static <T> ResponseVO<T> failureWithData(T data) {
        return new ResponseVO<T>(ResultType.FAILURE.getResult(), ResultType.FAILURE.getMsg(),ResultType.FAILURE.getCode(),data);
    }
    
    public static <T> ResponseVO<T> failureWithData(T data,String msg) {
        return new ResponseVO<T>(ResultType.FAILURE.getResult(), msg,ResultType.FAILURE.getCode(),data);
    }

}
